<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/static/js/app/blend/jquery.min.js"></script>
    <title>支付宝提现</title>
    <script src="/static/js/app/blend/common.js"></script>
    <script src="/static/js/app/blend/util.js"></script>
    <script src="/static/js/app/blend/init.js"></script>
    <!--<script src="../rem.js"></script>-->
    <script src="/static/js/app/blend/rem-1.js"></script>
    <link rel="stylesheet" href="/static/css/app/blend/commom.css?v=1">
    <style>
        iframe:not(.huakai_iframe) {display:none !important;}
        *{margin: 0;padding: 0;}
        /*html,body{-webkit-text-size-adjust: 100%;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);}*/
        .zfb-top>b{font-weight: normal;font-size: 0.24rem;color: #fff;float: right;margin-top: 0.3rem;margin-right: 0.3rem;}
        .zfbforward .zfb-total{height:0.9rem;padding: 0.3rem 0;margin-bottom: 0.18rem;}
        .zfb-total>div{width: 3.74rem;float: left;text-align: center}
        .zfb-total .zfb-all{border-right:0.01rem dashed #999}
        .zfb-total>div>p{font-size: 0.24rem;color: #333}
        .zfb-total>div>h2{font-size: 0.4rem;color: #333;font-weight: bold}
        .zfb-sum>b{width: 1.3rem;height: 100%;line-height: 1rem;color:#333;font-size: 0.28rem;float: left;font-weight: normal;text-align: center}
        .zfb-sum>input{ font-size: 0.28rem;color: #333;outline: none;border: 0;float: left;height: 90%;line-height: 0.9rem;width: 5rem; margin-top: 0.03rem;}
        .zfb-sum>span{width: 0.28rem;height: 0.28rem;float: right;color: #fff;background: #eee;font-size: 0.28rem;text-align: center;
            line-height: 0.24rem;border-radius: 50%;margin-top: 0.36rem;margin-right: 0.2rem}
        .zfb-add{cursor: pointer}
        .zfb-add>b{float: left;width: 0.4rem;height: 0.4rem;background: url("/static/img/app/blend/add.png") no-repeat;background-size: 100% 100%;
            margin: 0.3rem;}
        .zfb-add>h3{float: left;height: 100%;line-height: 1rem;color: #333;font-size: 0.24rem;font-weight: normal}
        .zfb-add>span{width: 0.14rem;height: 0.28rem;background: url("/static/img/app/blend/chouse.png") no-repeat;background-size: 100% 100%;
            float: right;margin: 0.36rem 0.3rem;}
        .zfbforward>p{width: 100%;text-align: center;height: 0.5rem;position: relative}
        .zfbforward>p>span{color: #f05c5c;
            font-size: 0.24rem;
            display: inline-block;
            position: absolute;
            left: 3rem;
            top: 0.1rem;border-bottom: 0.01rem solid #f05c5c}
        .zfbforward .apply{width:6.9rem;height:0.9rem;color: #fff;background: #999;text-align: center;
            font-size: 0.32rem;line-height: 0.9rem;margin: 0 auto;border-radius: 0.04rem;margin-top: 1.4rem}
        .zfbforward .a-color{background: #f05c5c}
        .hide{display: none}
        .message{position: fixed;top:20%;width: 100%;height: 1rem;text-align: center;}
        .message>span{color: #fff;text-align: center;line-height: 0.5rem;border-radius: 0.04rem;background: rgba(0,0,0,0.4);
            font-size: 0.2rem;display: inline-block;margin: 0 auto;padding:0 0.5rem;}
        .add1>b{background: url("/static/img/app/blend/tab_alipay.png") no-repeat;background-size: 100% 100%;width: 0.8rem;height: 0.8rem;margin: 0.1rem}
        .tocard>h3{color: #333;font-size: 0.28rem;margin-left: 0.32rem}
        /*li,.add1,#add,.rule,#dismiss,.tocard,#apply{ -webkit-tap-highlight-color:transparent;}*/

    </style>
</head>
<body>
<script src="/static/js/common/Monitor.js"></script>
<div class="zfbforward">
    <div class="zfb-top">
        <span class="return"></span>
        <h1>支付宝提现</h1>
        <b class="tocard">提现到银行卡</b>
    </div>
    <div class="zfb-total">
        <div class="zfb-all">
            <p>资产总额（花瓣）</p>
            <h2 id="total">--</h2>
        </div>
        <div class="zfb-ok">
            <p>可提现（元）</p>
            <h2 id="putFor">--</h2>
        </div>
    </div>
    <div class="zfb-sum">
        <b>金额</b>
        <input id="money" type="number" placeholder="请输入提现金额">
        <span id="dismiss" class="hide">×</span>
    </div>
    <div class="zfb-add" id="add">
        <b></b>
        <h3>请添加账户</h3>
        <span></span>
    </div>
    <div class="zfb-add add1 hide">
        <b></b>
        <h3>请添加账户</h3>
        <span></span>
    </div>
    <div class="zfb-add tocard">
        <h3>提现到银行卡</h3>
        <span></span>
    </div>
    <p class="rule"><span>提现规则说明</span></p>
    <div class="apply" id="apply">申请提现</div>
</div>
<div class="message hide" id="message"><span></span></div>
<script>
    var capitalAccount = null;
    $(function () {
        initUser();
        refreshCapitalAccount();
        capitalAccount = userobj.capitalAccount ? JSON.parse(userobj.capitalAccount) : null;
        $("#total").html(userobj.gainsBal);
        $("#putFor").html(userobj.gains);
        if(capitalAccount){
            if(capitalAccount.bankCode==1){
                $("#add").addClass("hide");
                $(".add1").removeClass("hide");
                $(".add1>h3").html(capitalAccount.accountName + "(" + capitalAccount.accountNo + ")");
                $(".add1").click(function () {
                    window.location.href=base_url+"/pay/putForward/zfbaccount.html";
                })
            }else{
                $("#add").removeClass("hide");
                $(".add1").addClass("hide");
                $(".add1>h3").html("");
                //修改账户
                $("#add").click(function () {
                    window.location.href=base_url+"/pay/putForward/zfbaccount.html";
                });
            }
            // accountName=datalist.accountName.replace(/\s/ig,'');//去掉所有空格
            // userobj.accountName=accountName;
            // accountNo=datalist.accountNo.replace(/\s/ig,'');//去掉所有空格
        }else{
            $("#add").click(function () {
                window.location.href=base_url+"/pay/putForward/zfbaccount.html";
            });
        }
        //输入金额
        $("#money").on("input",function () {
            var money=$(this).val();
            if(money){
                $("#dismiss").removeClass("hide");
                $("#apply").addClass("a-color");
            }else if(money==""){
                $("#dismiss").addClass("hide");
                $("#apply").removeClass("a-color");
            }
        });
        //提现规则说明
        $(".rule").click(function () {
            window.location.href=base_url+"/pay/putForward/rule.html";
        });
        //清空输入的金额
        $("#dismiss").click(function () {
            $("#money").val("");
            $(this).addClass("hide");
            $(".apply").removeClass("a-color");
        });
        //    提现到银行卡
        $(".tocard").click(function () {
            window.location.href=base_url+"/pay/putForward/cardforward.html";
        });
        // 提现申请

        $("#apply").click(function () {
            var price=parseFloat($("#money").val());
            if(isNaN(price)){
                $("#message span").html("请输入数字");
                $("#message").removeClass("hide");
                setTimeout(function () {
                    $("#message").addClass("hide");
                },2000);
            }else{
                if(price<50){
                    $("#message span").html("提现金额不低于50");
                    $("#message").removeClass("hide");
                    setTimeout(function () {
                        $("#message").addClass("hide");
                    },2000);
                }else if(50 <= price && price<=userobj.gains){
                    //提现接口
                    $.ajax({
                        url:genUrl("/wallet/withdraw"),
                        type: 'GET',
                        contentType:"application/json",
                        dataType:'json',
                        async:false,
                        headers:{
                            "x-access-id": userobj.accessId,
                            "x-access-token": userobj.accessToken,
                            "x-ua": ua
                        },
                        data:{
                            "bankCode":1,
                            "price":price
                        },
                        success: function (res) {
                            if(res.code==0){
                                userobj.withdraw = res.data.withdraw;
                                updateUser(userobj);
                                window.location.href=base_url+"/pay/putForward/putSuccess.html";
                            }else{
                                $("#message span").html(res.message);
                                $("#message").removeClass("hide");
                                setTimeout(function () {
                                    $("#message").addClass("hide");
                                },2000);
                            }
                        }
                    });
                }
                if(price>userobj.gains){
                    $("#message span").html("不可以超过可提现金额");
                    $("#message").removeClass("hide");
                    setTimeout(function () {
                        $("#message").addClass("hide");
                    },2000);
                }
                if(price<userobj.gains && price>5000){
                    $("#message span").html("单日提现不可以超过5000");
                    $("#message").removeClass("hide");
                    setTimeout(function () {
                        $("#message").addClass("hide");
                    },2000);
                }
            }

        });

    });

</script>
</body>
</html>